package com.spddr.pmos.jpa;

import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Embeddable;

import org.joda.time.DateTime;

@Embeddable
public class SettleResultId implements java.io.Serializable {
	private static final long serialVersionUID = 1L;

	private DateTime occur;
	private long trade;
	private long buyer;
	private long saler;
	private int period;

	public SettleResultId() {
	}

	public SettleResultId(DateTime occur, long trade, long saler, long buyer, int period) {
		this.occur = occur;
		this.trade = trade;
		this.saler = saler;
		this.buyer = buyer;
		this.period = period;
	}

	@Column(name = "occur", nullable = false, length = 16)
	@Convert(converter = cn.seqdata.jpa.converter.DateTimeConverter.class)
	public DateTime getOccur() {
		return this.occur;
	}

	public void setOccur(DateTime occur) {
		this.occur = occur;
	}

	@Column(name = "trade", nullable = false)
	public long getTrade() {
		return this.trade;
	}

	public void setTrade(long trade) {
		this.trade = trade;
	}

	@Column(name = "buyer", nullable = false)
	public long getBuyer() {
		return this.buyer;
	}

	public void setBuyer(long buyer) {
		this.buyer = buyer;
	}

	@Column(name = "saler", nullable = false)
	public long getSaler() {
		return this.saler;
	}

	public void setSaler(long saler) {
		this.saler = saler;
	}

	@Column(name = "period", nullable = false)
	public int getPeriod() {
		return this.period;
	}

	public void setPeriod(int period) {
		this.period = period;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + (int) (buyer ^ (buyer >>> 32));
		result = prime * result + ((occur == null) ? 0 : occur.hashCode());
		result = prime * result + (int) (trade ^ (trade >>> 32));
		result = prime * result + period;
		result = prime * result + (int) (saler ^ (saler >>> 32));
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		SettleResultId other = (SettleResultId) obj;
		if (buyer != other.buyer)
			return false;
		if (occur == null) {
			if (other.occur != null)
				return false;
		} else if (!occur.equals(other.occur))
			return false;
		if (trade != other.trade)
			return false;
		if (period != other.period)
			return false;
		if (saler != other.saler)
			return false;
		return true;
	}
}